//
//  LableAndTextFieldView.m
//  豆瓣
//
//  Created by aaaaaa on 16/6/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LableAndTextFieldView.h"

@interface LableAndTextFieldView ()<UITextFieldDelegate>

@property (nonatomic, retain) UILabel *lable;
@property (nonatomic, retain) UITextField *textField;

@end


@implementation LableAndTextFieldView

- (void)dealloc
{
    [_lable release];
    [_textField release];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    self.lable = [[UILabel alloc] initWithFrame:CGRectMake(25, 0, self.bounds.size.width * 0.25, self.bounds.size.height)];
    [self addSubview:_lable];
    [_lable release];
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(self.bounds.size.width * 0.25 + 25, 0, self.bounds.size.width * 0.65 , self.bounds.size.height)];
    [self addSubview:_textField];
    [_textField release];
    
    self.textField.layer.cornerRadius = 5;
    self.textField.layer.masksToBounds = NO;
    self.textField.layer.borderWidth = 1.0;
    self.textField.layer.borderColor = [UIColor colorWithRed:0.87f green:0.87f blue:0.87f alpha:1.00f].CGColor;
    self.textField.delegate = self;
}



- (void)setLableText:(NSString *)lableText{
    if (_lableText != lableText) {
        [_lableText release];
        _lableText = [lableText retain];
    }
    self.lable.text = lableText;
}

- (void)setTextFieldPlaceholder:(NSString *)textFieldPlaceholder{
    if (_textFieldPlaceholder != textFieldPlaceholder) {
        [_textFieldPlaceholder release];
        _textFieldPlaceholder = [textFieldPlaceholder retain];
    }
    self.textField.placeholder = textFieldPlaceholder;
}


- (void)setEncryption:(BOOL)encryption{
    _encryption = encryption;
    
    self.textField.secureTextEntry = encryption;
}


- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}








@end
